﻿package mortal.game.net.rmi
{
    import Engine.RMI.*;
    import Message.Game.*;
    import mortal.common.net.*;
    import mortal.game.manager.*;
    import mortal.game.net.*;

    public class GameRMI extends RMIBase
    {
        public var loginGameProxy:ILoginGamePrxHelper;
        public var iBagPrx:IBagPrxHelper;
        public var iMapPrx:IMapPrxHelper;
        public var iFightPrx:IFightPrxHelper;
        public var iRolePrx:IRolePrxHelper;
        public var iShopPrx:IShopPrxHelper;
        public var iPanicBuyPrx:IPanicBuyPrxHelper;
        public var iPetPrx:IPetPrxHelper;
        public var iInterPrx:IInterPrxHelper;
        public var iGroupPrx:IGroupPrxHelper;
        public var iFriendPrx:IFriendPrxHelper;
        public var iMailPrx:IMailPrxHelper;
        public var iMartketPrx:IMarketPrxHelper;
        public var iTrade:IBusinessPrxHelper;
        public var iPlayerPrx:IPlayerPrxHelper;
        public var iTask:ITaskPrxHelper;
        public var iCopy:ICopyPrxHelper;
        public var iDefenseCopy:IDefenseCopyPrxHelper;
        public var iEquip:IEquipPrxHelper;
        public var iMount:IMountPrxHelper;
        public var iGuild:IGuildPrxHelper;
        public var iSprite:ISpritePrxHelper;
        public var iTitlePrx:ITitlePrxHelper;
        public var iRankingPrx:IToplistPrxHelper;
        public var iAchievementPrx:IAchievementPrxHelper;
        public var iCheckIn:ICheckInPrxHelper;
        public var iQuestionCopyPrx:IQuestionPrxHelper;
        public var iFashion:IFashionPrxHelper;
        public var iActive:IActivePrxHelper;
        public var iActiveShop:IPanicBuyPrxHelper;
        public var iAutoArena:IAutoArenaPrxHelper;
        public var iHeroArena:IArena2PrxHelper;
        public var iTestPrx:ITestPrxHelper;
        private static var _instance:GameRMI;

        public function GameRMI()
        {
            this.loginGameProxy = new ILoginGamePrxHelper();
            this.iBagPrx = new IBagPrxHelper();
            this.iMapPrx = new IMapPrxHelper();
            this.iFightPrx = new IFightPrxHelper();
            this.iRolePrx = new IRolePrxHelper();
            this.iShopPrx = new IShopPrxHelper();
            this.iPanicBuyPrx = new IPanicBuyPrxHelper();
            this.iPetPrx = new IPetPrxHelper();
            this.iInterPrx = new IInterPrxHelper();
            this.iGroupPrx = new IGroupPrxHelper();
            this.iFriendPrx = new IFriendPrxHelper();
            this.iMailPrx = new IMailPrxHelper();
            this.iMartketPrx = new IMarketPrxHelper();
            this.iTrade = new IBusinessPrxHelper();
            this.iPlayerPrx = new IPlayerPrxHelper();
            this.iTask = new ITaskPrxHelper();
            this.iCopy = new ICopyPrxHelper();
            this.iDefenseCopy = new IDefenseCopyPrxHelper();
            this.iEquip = new IEquipPrxHelper();
            this.iMount = new IMountPrxHelper();
            this.iGuild = new IGuildPrxHelper();
            this.iSprite = new ISpritePrxHelper();
            this.iTitlePrx = new ITitlePrxHelper();
            this.iRankingPrx = new IToplistPrxHelper();
            this.iAchievementPrx = new IAchievementPrxHelper();
            this.iCheckIn = new ICheckInPrxHelper();
            this.iQuestionCopyPrx = new IQuestionPrxHelper();
            this.iFashion = new IFashionPrxHelper();
            this.iActive = new IActivePrxHelper();
            this.iActiveShop = new IPanicBuyPrxHelper();
            this.iAutoArena = new IAutoArenaPrxHelper();
            this.iHeroArena = new IArena2PrxHelper();
            this.iTestPrx = new ITestPrxHelper();
            if (_instance != null)
            {
                throw new Error(" GameRMI 单例 ");
            }
            new Regist();
            RMIDispatcher.getInstance().addEventListener(RMIEvent.RMI_ERROR, this.onRmiErrorHandler);
            return;
        }// end function

        private function onRmiErrorHandler(event:RMIEvent) : void
        {
            MsgManager.systemError(event.error);
            return;
        }// end function

        override public function set rmiSession(param1:RMISession) : void
        {
            param1.session.messageHandler = new MessageHandler();
            param1.session.communicator.sessionEvent = new RMISessionEvent();
            super.rmiSession = param1;
            return;
        }// end function

        public function close() : void
        {
            session.session.connection.close();
            return;
        }// end function

        override protected function initProxy() : void
        {
            session.registerProxy(this.loginGameProxy);
            session.registerProxy(this.iMapPrx);
            session.registerProxy(this.iFightPrx);
            session.registerProxy(this.iBagPrx);
            session.registerProxy(this.iRolePrx);
            session.registerProxy(this.iShopPrx);
            session.registerProxy(this.iPanicBuyPrx);
            session.registerProxy(this.iPetPrx);
            session.registerProxy(this.iGroupPrx);
            session.registerProxy(this.iFriendPrx);
            session.registerProxy(this.iPlayerPrx);
            session.registerProxy(this.iTask);
            session.registerProxy(this.iCopy);
            session.registerProxy(this.iDefenseCopy);
            session.registerProxy(this.iInterPrx);
            session.registerProxy(this.iEquip);
            session.registerProxy(this.iMailPrx);
            session.registerProxy(this.iMartketPrx);
            session.registerProxy(this.iTrade);
            session.registerProxy(this.iMount);
            session.registerProxy(this.iGuild);
            session.registerProxy(this.iSprite);
            session.registerProxy(this.iTitlePrx);
            session.registerProxy(this.iRankingPrx);
            session.registerProxy(this.iAchievementPrx);
            session.registerProxy(this.iCheckIn);
            session.registerProxy(this.iQuestionCopyPrx);
            session.registerProxy(this.iFashion);
            session.registerProxy(this.iActive);
            session.registerProxy(this.iActiveShop);
            session.registerProxy(this.iAutoArena);
            session.registerProxy(this.iHeroArena);
            session.registerProxy(this.iTestPrx);
            return;
        }// end function

        public static function get instance() : GameRMI
        {
            if (_instance == null)
            {
                _instance = new GameRMI;
            }
            return _instance;
        }// end function

    }
}
